package top.lingchen.demoreactor.reactor8;

import org.springframework.web.server.WebHandler;

import java.util.Observable;

/**
 * @Author 凌宸
 * @create 2021-12-01 下午 4:57
 * @Description
 * @Version 1.0
 */
public class ObserverDemo extends Observable {

    public static void main(String[] args) {
        ObserverDemo observerDemo = new ObserverDemo();
        // 添加观察者
        observerDemo.addObserver((o, arg) -> {
            System.out.println("发生变化");
        });
        observerDemo.addObserver((o, arg) -> {
            System.out.println("手动被观察者通知，准备改变");
        });
        observerDemo.setChanged(); // 数据变化
        observerDemo.notifyObservers(); // 通知
        /**
         * 手动被观察者通知，准备改变
         * 发生变化
         */
    }
}
